setup_glm
is used to setup the data/objects for any function that uses
the main GLM functionality in brainGraph
.
contrast_names
checks the dimensions of contrasts, generates contrast
names, and sets column names for GLM functions. For F-contrasts, if a
matrix
is given, it converts it to a list
to simplify processing
later.
add_nans
adds rows/columns (or higher dimensions) to model fit data
for regions which were skipped (due to having a singular design matrix,
usually).
cxtxfun_3d
returns a function that calculates the “CXtX”
matrix/array, used to calculate the standard error of a contrast. The
function signature will be f(contrast, xtx, rkC, ny)
.
glm_data_table
is used in brainGraph_GLM
and
brainGraph_mediate
to create a data.table
with the
subject IDs and column(s) for the graph- or vertex-level metric of
interest.
matrix2list
makes working with different contrast types (i.e., t or F)
a little simpler.
setup_glm(g.list, level, covars, X, contrasts, con.type, con.name, measure,
outcome, ...)contrast_names(contrasts, con.type, con.name, X)
check_if_singular(QR)
add_nans(fits, dimX, namesX, runX = names(fits$qr))
cxtxfun_3d(con.type, transpose = TRUE)
glm_data_table(g.list, level, measure)
matrix2list(mat)
maxfun(alternative)
sortfun(alternative)
contrast_names
-- list containing the contrasts (matrix or
list), contrast names, and number of contrasts
add_nans
-- the original fits
object with NaN
or
NA
inserted
cxtxfun_3d
-- A function with arguments for the contrast
(numeric matrix), the “unscaled covariance” array, the (row) rank of
the contrast, and the number of regions in the analysis (only used for
F-contrasts)
glm_data_table
- A data.table
with one column
containing the subject ID's and 1 or more columns with the graph- or
vertex-level measure of interest.
matrix2list
-- A list with length equal to the number of rows
of C
A brainGraphList
object
Character string; either vertex
(default) or
graph
A data.table
of covariates
Numeric matrix, if you wish to supply your own design matrix.
Ignored if outcome != measure
.
Numeric matrix (for T statistics) or list of matrices (for F statistics) specifying the contrast(s) of interest; if only one contrast is desired, you can supply a vector (for T statistics)
Either 't'
or 'f'
Character vector of the contrast name(s); if contrasts
has row/list names, those will be used for reporting results
Character string of the graph measure of interest
Character string specifying the name of the outcome variable,
if it differs from the graph metric (measure
)
Arguments passed to brainGraph_GLM_design
List of QR decompositions for each design matrix
List object output by one of the model fitting functions (e.g.,
fastLmBG
)
Integer vector containing the dimensions of the original design matrix/array (including singular designs)
List of character vectors containing the dimension names from the original design matrix/array
Character vector of regions for which models were fit
Logical indicating whether to transpose the output of the
selected function. Ignored for F-contrasts. Should be FALSE
for
T-contrasts when the “Guttman” partition method is used. Default:
TRUE
Numeric matrix in which each row is a single contrast vector
Character string, whether to do a two- or one-sided test.
Default: 'two.sided'
This function: removes unused levels from covars
and DT.y.m
,
removes subjects with incomplete data, creates a design matrix (if not
supplied), and supplies names to the contrast matrix.
The “CXtX” matrix/array for T-contrasts is the diagonal of $$C (X^T X)^{-1} C^T$$ For F-contrasts, it is the inverse of the matrix: $$(C (X^T X)^{-1} C^T)^{-1}$$ where in both cases, \(C\) is the contrast matrix and \(X\) is the design matrix/array.
For T-contrasts, the function will return a numeric vector/matrix with dimensions \(k \times r\) where \(k\) is the number of contrasts (i.e., the number of rows in the contrast matrix) and \(r\) is the number of regions. For F-contrasts, the function would return a numeric array with dimensions \(k \times k \times r\), where \(k\) is the rank of the contrast matrix and \(r\) is the number of regions. If there is a single design for all regions, it will be a \(k \times k\) matrix.